<?php

/**
 * CodeRS - Atviras kodas Lietuvai
 * Copyright (C) 2007 CodeRS www.coders.lt info@coders.lt
 * MightMedia TVS
 * Blokas - "kas naujo". Rodo tik atsinaujinusia informaciją po paskutinio apsilankymo
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 * 
 * 
 * Ši programa yra laisva. Jūs galite ją platinti ir/arba modifikuoti
 * remdamiesi Free Software Foundation paskelbtomis GNU Bendrosios
 * Viešosios licencijos sąlygomis: 2 licencijos versija, arba (savo
 * nuožiūra) bet kuria vėlesne versija.
 * 
 * Ši programa platinama su viltimi, kad ji bus naudinga, bet BE JOKIOS
 * GARANTIJOS; be jokios numanomos PERKAMUMO ar TINKAMUMO KONKRETIEMS
 * TIKSLAMS garantijos. Žiūrėkite GNU Bendrąją Viešąją licenciją norėdami
 * sužinoti smulkmenas.
 * 
 * Jūs turėjote kartu su šia programa gauti ir GNU Bendrosios Viešosios
 * licencijos kopija; jei ne - rašykite Free Software Foundation, Inc., 59
 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**/

if ($_SERVER['PHP_SELF'] == __FILE__) { header('location: ?'); exit(); }

if (PRISIJUNGES) {
	$text='';
	$q = $db->uzklausa("SELECT `id`,`tid`,`pav` FROM `".LENTELES_PRIESAGA."d_straipsniai` WHERE `last_data` >= ".escape($ses->user_data['lastlogin'])." ORDER BY `last_data` DESC LIMIT 0,5",__FILE__,__LINE__);
	if ($db->rows($q) > 0) {
		$text .= "<b>Forumų:</b><br/>";
		while ($row = $db->masyvas($q)) {
			$text .= "\t <img src=\"images/icons/bullet2.gif\" alt=\"o\" class=\"middle\" border=\"0\"/> <a href='?id,25;t,".$row['tid'].";s,".$row['id']."#end'>".substr(input($row['pav']),0,20)."...</a><br />\n";
		}
	}

	$q = $db->uzklausa("SELECT `id`, `pid`, `pav`, `t_text`, `date`, `autorius` FROM `".LENTELES_PRIESAGA."straipsniai` WHERE date>=".escape($ses->user_data['lastlogin'])." LIMIT 10",__FILE__,__LINE__);
	if ($db->rows($q) > 0) {
		$text .= "<hr/><b>Straipsnių:</b><br/>";
		while ($row = $db->masyvas($q)) {
			//?id,22;p,16;t,6
			$text .= "<img src=\"images/icons/bullet2.gif\" alt=\"o\" class=\"middle\" border=\"0\"/> <a href='?id,22;p,".$row['pid'].";t,".$row['id']."' title=\"header=[".input($row['pav'])."] body=[<br/>Autorius: <b>".$row['autorius']."</b><br/>Data: <b>".$row['date']."</b><br/>Kada: <b>".kada($row['date'])."</b><br/>Trumpai: <i>".input($row['t_text'])."</i><br/>] cssbody=[sarasas] cssheader=[title] fade=[on]\">".substr(input($row['pav']),0,20)."...</a><br />\n";
		}
	}
	$q = $db->uzklausa("SELECT `id`, `pavadinimas` FROM `".LENTELES_PRIESAGA."naujienos` WHERE `data`>=".escape($ses->user_data['lastlogin'])." ORDER BY `data` DESC LIMIT 10",__FILE__,__LINE__);
	if ($db->rows($q) > 0) {
		$text .= "<hr/><b>Naujienų:</b><br/>";
		while ($row = $db->masyvas($q)) {
			//?id,50;k,22
			$text .= "<img src=\"images/icons/bullet2.gif\" alt=\"o\" class=\"middle\" border=\"0\"/> <a href='?id,50;k,".$row['id']."'>".substr(input($row['pavadinimas']),0,20)."...</a><br />\n";
		}
	}
	$q = $db->uzklausa("SELECT `id`, `pav` FROM `".LENTELES_PRIESAGA."codebin` WHERE `data`>=".escape($ses->user_data['lastlogin'])." ORDER BY `data` DESC LIMIT 10",__FILE__,__LINE__);
	if ($db->rows($q) > 0) {
		$text .= "<hr/><b>CodeBin:</b><br/>";
		while ($row = $db->masyvas($q)) {
			//index.php?id,50;k,22
			$text .= "<img src=\"images/icons/bullet2.gif\" alt=\"o\" class=\"middle\" border=\"0\"/> <a href='?id,7;c,".$row['id']."'>".substr(input($row['pav']),0,20)."</a><br />\n";
		}
	}
	$q = $db->uzklausa("SELECT * FROM `".LENTELES_PRIESAGA."kom` WHERE `data`>='".$db->fix($ses->user_data['lastlogin'])."' ORDER BY `data` DESC LIMIT 10",__FILE__,__LINE__);
	if ($db->rows($q) > 0) {
		$text .= "<hr/><b>Komentarai:</b><br/>";
		while ($row = $db->masyvas($q)) {
			//?id,50;k,22
			if ($row['pid'] == 7) { $extra = "CodeBin"; $link = "c,".$row['kid'].""; } //CODEBIN ?id,7;c,59
			elseif ($row['pid'] == 50) { $extra = "Naujienos"; $link = "k,".$row['kid']; }
			elseif ($row['pid'] == 6) { $extra = "Siuntiniai"; $link = "v,".$row['kid']; } //siuntiniai ?id,50;k,25#162
			elseif ($row['pid'] == 22) { $extra = "Straipsniai"; $link = "t,".$row['kid']; }	//?id,22;p,14;t,14#325
			elseif ($row['pid'] == 7) {  }
			elseif ($row['pid'] == 7) {  }
			elseif ($row['pid'] == 7) {  }
			$text .= "<img src=\"images/icons/bullet2.gif\" alt=\"o\" class=\"middle\" border=\"0\"/> <a href='?id,".$row['pid'].";".$link."#".$row['id']."' title=\"header=[$extra] body=[<br/>Autorius: <b>".$row['nick']."</b><br/>Data: <b>".$row['data']."</b><br/>Kada: <b>".kada($row['data'])."</b><br/><br/>] cssbody=[sarasas] cssheader=[title] fade=[on]\">".substr(input($row['zinute']),0,20)."...</a><br />\n";
		}
	}


	if (isset($text) && !empty($text)) { style_blockHide("Kas naujo svetainėje",$text); }
	unset($text);
}
?>
